﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Data;

/**
 * 创建时间：2014/12/8 13:20:36
 * 作者：yong.blackcore
 * Email：itblackhole@outlook.com
 * QQ：50404503
 */
namespace ComicIsland.Common.Converter
{
    public class BookStoreAlbumBindingConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                if (value == null)
                    return string.Empty;
                string currentValue = value.ToString();
                if (string.IsNullOrWhiteSpace(currentValue.Trim()))
                    return string.Empty;
                //p.Id, KEYS.SPLITSTRING, p.Name, KEYS.SPLITSTRING, p.Targetmethod, KEYS.SPLITSTRING, p.Targetargument
                string[] values = Regex.Split(currentValue, KEYS.SPLITSTRING);
                if (values != null && values.Length == 4)
                {
                    return values[1];
                }
                return string.Empty;
            }
            catch (Exception err)
            {
                LogHelper.LogError(err.Message, this.GetType(), MethodBase.GetCurrentMethod());
                return string.Empty;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return null;
        }
    }
}
